﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace 享元模式
{
    //享元工厂类
    class FlyweightFactory
    {
        public Hashtable flyweight = new Hashtable();

        public FlyweightFactory()
        {
            flyweight.Add("A",new ConcreteFlyweight("A"));
            flyweight.Add("B", new ConcreteFlyweight("B"));
            flyweight.Add("C", new ConcreteFlyweight("C"));
        }

        public Flyweight GetFlyweight(string key)
        {
            return flyweight[key] as Flyweight;
         }
    }
}
